package com.czk.scala.chapter05

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/21 17:44
 */
object Test08_Practice_1 {
  def main(args: Array[String]): Unit = {
    // 匿名函数的练习
    val fun = (i: Int, s: String, c: Char) => {
      if (i == 0 && s == "" && c == '0') {
        false
      } else {
        true
      }
    }
    println(fun(0, "", '0'))
  }

  // 函数的嵌套
  // 返回值是f1
  def func(i: Int): String => (Char => Boolean) = {
    // 返回值是f2
    def f1(s: String): Char => Boolean = {
      def f2(c: Char): Boolean = {
        if (i == 0 && s == "" && c == '0') {
          false
        } else {
          true
        }
      }
      f2
    }
    f1
  }
  println(func(1)("")('0'))
}
